<script type="text/javascript">
function validate_form() {
    <?php
        if(count($this->language) > 0) :
            foreach($this->language as $value) :
    ?>
    if($('#tabs-<?php echo $value['locale'] ?>').hasClass('ui-tabs-hide') == false) {
        var image = $('#image').val();
        var title_<?php echo $value['locale'] ?> = $('#title-<?php echo $value['locale'] ?>').val();
        var description_<?php echo $value['locale'] ?> = tinyMCE.get('description-<?php echo $value['locale'] ?>').getContent();
        var countError = 0;
        if((title_<?php echo $value['locale'] ?>.length < 1) || (title_<?php echo $value['locale'] ?>.length > 300)) {
            $('#errorTitle-<?php echo $value['locale'] ?>').html('Tiêu đề từ 1-300 kí tự');
            countError++;
        }
        else {
            $('#errorTitle-<?php echo $value['locale'] ?>').html('');
        }
        if(description_<?php echo $value['locale'] ?> == '') {
            $('#errorDescription-<?php echo $value['locale'] ?>').html('Nội dung không được để trống');
            countError++;
        }
        else {
            $('#errorDescription-<?php echo $value['locale'] ?>').html('');
        }
        if(!/(\.png|\.bmp|\.gif|\.jpg|\.jpeg\.PNG|\.BMP|\.GIF|\.JPG|\.JPEG)$/i.test(image)) {
            $('#errorImage').html('Ảnh phải đúng định dạng jpg, jpeg, bmp, png, gif');
            countError++;
        }
        else {
            $('#errorImage').html('');
        }
        if(countError > 0) {
            return false;
        }
        else {
            return true;
        }
    }
    <?php
            endforeach;
        endif;
    ?>
};
</script>
<div class="list_category">
        <ul>
            <li><a href="<?php echo $this->baseUrl('admincp/article'); ?>">Quản lý cảnh điểm</a></li>
        </ul>
    </div>
</div>

<!-- Begin Content -->
<div class="section">
    <div class="heading_section">
        <span>Tạo bài viết mới</span>
    </div>
    
    <div class="content">
    <form action="" method="post" onsubmit="return validate_form()" enctype="multipart/form-data">
        <div id="tabs">
            <ul>
                <?php
                    if(count($this->language) > 0) :
                        foreach($this->language as $value) :
                ?>
                    <li><a href="#tabs-<?php echo $value['locale']; ?>"><?php echo $value['name']; ?></a></li>
                <?php
                        endforeach;
                    endif;
                ?>
            </ul>
            <?php
                if(count($this->language) > 0) :
                    foreach($this->language as $value) :
            ?>
            <div id="tabs-<?php echo $value['locale']; ?>">
                <table class="table">
                    <tr>
                        <td class="td1"><?php echo $this->formLabel('title-'.$value['locale'],'Tiêu đề'); ?>&nbsp;<span class="error-msg">*</span></td>
                        <td class="td2"><?php echo $this->formText('title-'.$value['locale'],null,array('class'=>'input','style'=>'width: 500px')); ?></td>
                        <td class="td3" id="errorTitle-<?php echo $value['locale']; ?>"></td>
                    </tr>
                    <tr>
                        <td class="td1"><?php echo $this->formLabel('description-'.$value['locale'],'Nội dung'); ?>&nbsp;<span class="error-msg">*</span></td>
                        <td class="td2"><?php echo $this->formTextarea('description-'.$value['locale'],null,array('class'=>'ckeditor')); ?></td>
                        <td class="td3" id="errorDescription-<?php echo $value['locale']; ?>"></td>
                    </tr>
                </table>
            </div>
            <?php
                    endforeach;
                endif;
            ?>
            
            <table class="table">
                <tr>
                    <td class="td1"><?php echo $this->formLabel('location_id', 'Địa điểm'); ?></td>
                    <td class="td2">
                        <select name="location_id" id="location_id" class="selectbox">
                        <?php
                            if(count($this->location) > 0) :
                                foreach($this->location as $value) :
                        ?>
                            <option value="<?php echo $value['id']; ?>"><?php echo $value['name']; ?></option>
                        <?php
                            endforeach;
                            endif;
                        ?>
                        </select>
                    </td>
                    <td class="td3"></td>
                </tr>
                <tr>
                    <td class="td1"><?php echo $this->formLabel('image', 'Ảnh bài viết'); ?></td>
                    <td class="td2"><input type="file" name="image" id="image" /></td>
                    <td class="td3" id="errorImage"></td>
                </tr>
                <tr>
                    <td class="td1">&nbsp;</td>
                    <td class="td2">
                        <?php echo $this->formSubmit('submit','Chấp nhận',array('class'=>'button')); ?>
                        <?php echo $this->formReset('reset','Nhập lại',array('class'=>'button')); ?>
                    </td>
                    <td class="td3"></td>
                </tr>
            </table>
        </div>
    </form>
    </div>
</div>
<!-- End Content -->